﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EmaMetadata;
using System.IO;

namespace MetadataTest
{
    [TestClass]
    public class UnitTest4
    {
        [TestMethod]
        public void TimothyUnitTest()
        {
            EmaBatch b = Factory.LoadBatch("C:\\EMAXMLPoject\\SampleXML\\Halo_4_Test.xml");

            // File should have one product
            Assert.AreEqual(b.Products.Count, 1);

            // Okay, let's examine this product
            EmaProduct p = b.Products[0];

            // Verify that its identities loaded correctly
            Assert.AreEqual(p.GetIdentity("org.gs1", "GTIN-14").Value, "00014633098891");
            Assert.AreEqual(p.GetIdentity("com.eedar", "EEDAR").Value, "219511");
            Assert.AreEqual(p.GetIdentity("com.microsoft", "GUID").Value, "{0002E101-0000-0000-C000-000000000046}");

            // Verify that all the titles are correct
            Assert.AreEqual(p.GetTitle("org.entmerch", "Complete").Value, "Halo 4: Legendary Edition"); //GetIdentity returns an EmaTitle, and Value is a string variable of that EmaTitle
            Assert.AreEqual(p.GetTitle("org.entmerch", "Medium").Value, "Halo 4");
            Assert.AreEqual(p.GetTitle("org.entmerch", "Brief").Value, "Halo 4");
            Assert.AreEqual(p.GetTitle("org.entmerch", "Sorting").Value, "Halo 4");

            // Verify descriptions
            Assert.AreEqual(p.GetDesc("org.entmerc", "short").Value, "Halo 4 is the fourth installment in the Halo series where Master Chief returns to battle an ancient evil bent on vengeance and annihilation.");
            Assert.AreEqual(p.GetDesc("org.entmerc", "long").Value, "Halo 4 is a first-person shooter video game developed by 343 Industries and published by Microsoft Studios for the Xbox 360 video game console. The game was released in most territories worldwide on November 6, 2012. Halo 4's story begins four years after the ending of Halo 3; the player assumes the role of the Master Chief, a cybernetically-enhanced supersoldier. The story is mainly set on a Forerunner planet, where Master Chief encounters the collection of alien races known as the Covenant and ancient warriors of the Forerunner empire known as the Prometheans. Master Chief is accompanied by the artificial intelligence construct Cortana.");
            Assert.AreEqual(p.GetDesc("org.entmerc", "requirements").Value, "1 Controllor, 4 MB to save game, at least 8 GB hard drive space, internet connection required for online play");


            // Verify a couple hand selected facts
            Assert.AreEqual(p.EditionType.Name, "Legendary");
            Assert.AreEqual(p.MaxPlayers, 16);
            Assert.AreEqual(p.Platform.Name, "Xbox 360");

            // Verify a couple hand selected facts
            Assert.AreEqual(p.PrimaryDeveloper, "343 Industries");
        }
        public void SaveAndLoadTest()
        {
            // Read in the test file from ted's sample data folder
            EmaBatch b = Factory.LoadBatch("..\\..\\..\\..\\SampleXML\\schema_template.xml");

            // Save this record to a string
            string xml = Factory.SaveBatchToString(b);

            // Reload the string back into a batch
            EmaBatch reloaded = Factory.LoadBatchFromString(xml);
        }


        }
    }

